import { stringify } from 'qs';
import request from '@/utils/request';
import { getPageSize } from '@/utils/common';

//一、事件关联表
export async function eventsList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/sms/sms-events/selectSmsEventsList`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 新增编辑
 */
export async function eventsOperate(params) {
  const url = params.id ? 'sms-events/updateSmsEvents' : 'sms-events/insertSmsEvents';

  return request(
    `/server/api/sms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}
//启用禁用
export async function ableOperate(params) {
  const url = params.type ? 'sms-events/enableEvents' : 'sms-events/disabledEvents';
  return request(
    `/server/api/sms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

export async function eventsDetails(params) {
  return request(
    `/server/api/sms/sms-events/viewSmsEventsDetails`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}
//二、事件接收方：
export async function eventReceiverList(params) {
  return request(`/server/api/sms/sms-event-receiver/selectSmsEventReceiverList`, {
    method: 'POST',
    body: params,
  });
}
/**
 * 新增编辑
 */
export async function eventReceiverOperate(params) {
  const url = params.id
    ? 'sms/sms-event-receiver/updateSmsEventReceiver'
    : 'sms-event-receiver/insertSmsEventReceiver';

  return request(
    `/server/api/sms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

export async function eventReceiverDelete(params) {
  return request(`/server/api/sms/sms-event-receiver/deleteSmsEventReceiver`, {
    method: 'POST',
    body: params,
  });
}

// 三、消息内容
export async function msgContentList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/sms/sms-event-content/selectSmsEventContentList`, {
    method: 'POST',
    body: params,
  });
}

//四、消息发送方账号管理：
export async function sendertList(params) {
  params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/sms/sms-sender/selectSmsSenderList`, {
    method: 'POST',
    body: params,
  });
}
// 消息内容重试  sms/sms-event-content/retryMessageSend
export async function retryMsgSend(params) {
  return request(`/server/api/sms/sms-event-content/retryMessageSend`, {
    method: 'POST',
    body: params,
  });
}
/**
 * 新增编辑
 */
export async function senderOperate(params) {
  const url = params.id ? 'sms-sender/updateSmsSender' : 'sms-sender/insertSmsSender';

  return request(
    `/server/api/sms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

//启用禁用
export async function ableSenderOperate(params) {
  const url = params.type ? 'sms-sender/enableSender' : 'sms-sender/disabledSender';
  return request(
    `/server/api/sms/${url}`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

export async function senderDetails(params) {
  return request(
    `/server/api/sms/sms-sender/viewSmsSenderDetails`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

// 规则选择列表
export async function selectReleaseRuleList(params) {
  return request(`/server/api/mds/rule-menu-content/selectReleaseRuleList`, {
    method: 'POST',
    body: params,
  });
}
